home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / SoftTimer / SoftTimer.ReadMe < prev    next >
Encoding:
Text File  |  1998-06-15  |  4.2 KB  |  138 lines

  1. SoftTimer-module by Deniil 715!
  2.  
  3.  
  4. What is it?
  5. ~~~~~~~~~~~
  6. SoftTimer_oo.m contains a class that uses the timer.device for
  7. delay of microseconds and/or seconds.
  8.  
  9.  
  10. Usage of the class methods:
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. DEF st:PTR TO softtimer
  13.  
  14. -----------------
  15. softtimer(pri=0,doNotRaise=FALSE) -> This is the constructor to the class.
  16. ^^^^^^^^^
  17. Usage: NEW st.softtimer() -> will initiate the timer with default values.
  18.  
  19. 'pri' can be 32, 16, 0, -16, -32, default is 0.
  20. 'doNotRaise' can be set nonzero if you don't want failures to be
  21.              reported as raised exceptions but manually checked
  22.              through 'st.err'
  23.              Default is FALSE. Recommended to keep it that way!
  24. -----------------
  25.  
  26. startTimer(secs,micro=0) -> This will start the timer with specified
  27. ^^^^^^^^^^                  time-values.
  28.  
  29. Usage: st.startTimer(5,300000) -> will wait 5.3 seconds.
  30.  
  31. 'secs' is how many seconds you want the timer to run before it
  32.        signals your task on sigbit 'st.sig'.
  33. 'micro' is how many microseconds you want the timer to run before
  34.         it signals your task as with seconds.
  35.         Default is 0 microsecs.
  36. -----------------
  37.  
  38. stopTimer() -> will stop a running timer.
  39. ^^^^^^^^^
  40. Usage: st.stopTimer()
  41. -----------------
  42.  
  43. delay(secs,micro=0) -> will wait the specified time.
  44. ^^^^^
  45. Usage: st.delay(120) -> will wait 2 minutes.
  46.  
  47. 'secs' and 'micro' is the same as for startTimer().
  48.  
  49. -----------------
  50.  
  51. waitForTimer() -> will wait for the timer to finish and then return.
  52. ^^^^^^^^^^^^
  53. Usage: st.waitForTimer()
  54.  
  55. NOTE: This call could be dangerous if you're unsure of the remaining
  56.       time that the timer will run couse your task will be frozen
  57.       until the timer has finished!
  58. -----------------
  59.  
  60. waitForThings(signals=0) -> waits for the timer AND any other signal
  61. ^^^^^^^^^^^^^               that might arrive.
  62.                             The function of this method is equal to
  63.                             Wait(signals OR st.sig).
  64.  
  65. Usage: st.waitForTimer(Shl(1,win.userport.sigbit))
  66.        This call will now wait for signals from the timer and
  67.        the userport of the window 'win'.
  68.  
  69. 'signals' is the same signal-mask that you pass can to Wait().
  70.  
  71. NOTE: Wait() is in my opinion to prefer as it is less code
  72.       to write and it is faster than waitForThings().
  73. -----------------
  74.  
  75. waitAndRestart(secs,micro=0) -> will wait until a running timer finishes
  76. ^^^^^^^^^^^^^^                  and then restart it as the startTimer()
  77.                                 does.
  78.                                 This method could be useful for demos,
  79.                                 games etc.
  80.  
  81. Usage: FOR x:=0 TO 100
  82.         st.waitAndRestart(0,100000) -> wait 1/10 of a second
  83.         -> doStuffThatShouldBeDoneTenTimesASecond()
  84.        ENDFOR
  85.  
  86. 'secs' and 'micro' is the same as for startTimer().
  87. -----------------
  88.  
  89. getTimerMsg() -> is used to check if your timer has finished or not.
  90. ^^^^^^^^^^^
  91. Usage: IF st.getTimerMsg()=TRUE
  92.         WriteF('Timer counted to zero!\n')
  93.        ELSE
  94.         WriteF('Timer still running!\n')
  95.        ENDIF
  96. -----------------
  97.  
  98. end() -> destructor that will deallocate all messageports and stuff.
  99. ^^^
  100. Usage: END st -> END will search the softtimer for an end()-method
  101.                  and execute it as st.end().
  102.  
  103. NOTE: This could be used as just st.end() if you later want to reuse
  104.       it without NEW, just st.softtimer(). Not recommended though!
  105. -----------------
  106.  
  107.  
  108. Errors?
  109. ~~~~~~~
  110. Errors will normally be raised as exceptions. However, if you specify
  111. doNotRaise=TRUE when you initiate the softtimer you have to check the
  112. errors by yourself by compare the st.err against theese errors:
  113.  
  114. ERR_MSGPORT -> The message-port coouldn't be created. (CreateMsgPort())
  115. ERR_TIMER   -> The timerequest couldn't be created.   (createStdIO())
  116. ERR_DEV     -> The timer.device couldn't be opened.   (OpenDevice())
  117.  
  118. ERR_NONE    -> Everything went well and you're ready to use your timer.
  119.                This will never be raised since it's not an error.
  120.  
  121. Remember that the NEW-keyword might raise itself if out of memory!!
  122.  
  123.  
  124. Author?
  125. ~~~~~~~
  126. Daniel Westerberg  alias  Deniil715!
  127. E-mail: deniil@algonet.se  or  onyxsoft@alfaskop.net
  128.  
  129.  
  130. Bugs?
  131. ~~~~~
  132. Don't think so ;)
  133. Report to author if you find anyone!  (please don't find any!!:)
  134.  
  135. It has been tested on:
  136. A1200 Blizz1230/50 OS39 2+16 MB Ram DBLPal ..
  137.  
  138.